package com.dqhl.community.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.dqhl.community.R;
import com.dqhl.community.base.BaseMyAdapter;

import java.util.List;

/**
 * Created by LIENLIN on 2016/9/10.
 */
public class PhotoAdapter extends BaseMyAdapter {

    private List<String>list;
    public PhotoAdapter(Context context,List<String>list) {
        super(context);
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size()+1;
    }

    @Override
    public String getItem(int i) {
        if (i!=0){
            return list.get(i-1);
        }
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        View inflate = inflater.inflate(R.layout.gv_health_photo_item, viewGroup, false);
        ImageView iv= (ImageView) inflate.findViewById(R.id.iv_health_photo);
        if (i==0){
            iv.setImageResource(R.drawable.addimage);
        }else {
            Drawable drawable =Drawable.createFromPath(list.get(i-1));
            iv.setImageDrawable(drawable);
        }

        return inflate;
    }
}
